﻿using System.ServiceModel.DomainServices.Client;
using System.Windows;
using System.Windows.Controls;
using AdventureWorksLT.Views.Customers.ViewModels;
using AdventureWorksLT.Web.Services;

namespace AdventureWorksLT.Views.Customers.ChildWindows
{
    public partial class CustomerAddCW : ChildWindow
    {
        
        readonly int loadedCustomerID = AdventureWorksLT.Views.Customers.ViewModels.CustomersViewModel.DashLoad_PK;
        //private int loadedPatient_Id = 1;
        
        public CustomerAddCW()
        {
            InitializeComponent();
            
        }


        private void OKButton_Click(object sender, RoutedEventArgs e)
            {
                CustomerIDTextBox.Text = loadedCustomerID.ToString(); //make sure is not the primary key of the current form, it needs to be a FOREIGN key.
            if (!CustomersViewModel.CustomersContext.IsLoading)
                {
                    this.CustomerDataForm.CommitEdit();
                    this.DialogResult = true;
                }
            }
            
        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
            this.Close();
        }
        



            private void CustomerDataForm_EditEnded(object sender, DataFormEditEndedEventArgs e)
            {
                this.Close();
            }

    }
}

